import 'package:flutter/material.dart';

class CustomTaBar extends StatefulWidget {
  final Function(int) changeIndex;
  const CustomTaBar({super.key, required this.changeIndex});

  @override
  State<StatefulWidget> createState() => MyTab();
}

class MyTab extends State<CustomTaBar> {
  int _ind = 0;
  @override
  Widget build(BuildContext context) {
    return BottomNavigationBar(
      backgroundColor: Colors.blue,
      currentIndex: _ind, // 设置当前选中的tab
      fixedColor: Colors.white, // 设置tab选中的颜色
      //   selectedItemColor: Colors.white,
      unselectedItemColor: Colors.black,
      iconSize: 25, // 设置图标的大小
      type: BottomNavigationBarType.fixed, // 如果tab大于3个，则需要设置该属性才能显示
      items: const [
        // 设置tabbar按钮
        BottomNavigationBarItem(icon: Icon(Icons.home), label: "双色球"),
        BottomNavigationBarItem(
          icon: Icon(Icons.account_circle),
          label: "干支纪年",
        ),
      ],
      onTap: (index) {
        _ind = index;
        widget.changeIndex(index);
      },
    );
  }
}
